//
//  JXHomeActionView.m
//  JXAddressApp
//
//  Created by zhhw_home on 2018/11/4.
//  Copyright © 2018年 zhhw_home. All rights reserved.
//

#import "JXHomeActionView.h"
#import "QMUIButton.h"
#import "QMUICommonDefines.h"
#import "UIColor+QMUI.h"
#import <QMUITips.h>

@interface JXHomeActionView()

@property (nonatomic, strong) QMUIButton *zanButton;
@property (nonatomic, strong) QMUIButton *modifyButton;

@end

@implementation JXHomeActionView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        _zanButton = [[QMUIButton alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH/2, 40)];
        _zanButton.imagePosition = QMUIButtonImagePositionLeft;
        _zanButton.spacingBetweenImageAndTitle = 10.f;
        [_zanButton setTitle:@"点赞" forState:UIControlStateNormal];
        [_zanButton setImage:[UIImage imageNamed:@"praise"] forState:UIControlStateNormal];
        [_zanButton addTarget:self action:@selector(zanClick) forControlEvents:UIControlEventTouchUpInside];
        [_zanButton setTitleColor:[UIColor qmui_colorWithHexString:@"#666666"] forState:UIControlStateNormal];
        [self addSubview:_zanButton];
        
        _modifyButton = [[QMUIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2, 0, SCREEN_WIDTH/2, 40)];
        _modifyButton.imagePosition = QMUIButtonImagePositionLeft;
        _modifyButton.spacingBetweenImageAndTitle = 10.f;
        [_modifyButton setTitle:@"纠错" forState:UIControlStateNormal];
        [_modifyButton setImage:[UIImage imageNamed:@"editor"] forState:UIControlStateNormal];
        [_modifyButton addTarget:self action:@selector(modifyClick) forControlEvents:UIControlEventTouchUpInside];
        [_modifyButton setTitleColor:[UIColor qmui_colorWithHexString:@"#666666"] forState:UIControlStateNormal];
        [self addSubview:_modifyButton];
    }
    
    return self;
}

- (void)zanClick
{
    [QMUITips showInfo:@"点赞成功" inView:self hideAfterDelay:0.4];
}

- (void)modifyClick
{
    if (_editorBlock) {
        _editorBlock();
    }
}

@end
